﻿// <copyright file="TimesPeopleFollowers.cs" company="Microsoft Corporation">
// Copyright (c) 2009 Microsoft Corporation All Rights Reserved
// </copyright>
// <author>Michael S. Scherotter</author>
// <email>mischero@microsoft.com</email>
// <date>2009-05-07</date>
// <summary>TimesPeopleFollowers class definition</summary>

namespace NYTimes
{
    using System;
    using System.Collections.ObjectModel;
    using NYTimes.Core;
    using NYTimes.Data;

    /// <summary>
    /// New York Times TimesPeople Followers API
    /// </summary>
    public class TimesPeopleFollowers : TimesPeople
    {
        /// <summary>
        /// Initializes a new instance of the TimesPeopleFollowers class.
        /// </summary>
        public TimesPeopleFollowers()
        {
            this.Users = new ObservableCollection<Profile>();
        }

        /// <summary>
        /// Gets the "followers" data type
        /// </summary>
        public override string DataType
        {
            get { return "followers"; }
        }

        /// <summary>
        /// Gets the users as an observable collection of <see cref="NYTimes.Data.Profile"/> 
        /// objects.
        /// </summary>
        public ObservableCollection<Profile> Users { get; private set; }

        /// <summary>
        /// Parse the result set
        /// </summary>
        /// <param name="resultSet">the Result set</param>
        public override void ParseResultSet(System.Xml.Linq.XElement resultSet)
        {
            ParseUsers(resultSet, this.Users);
        }

        /// <summary>
        /// Clear the user list
        /// </summary>
        /// <param name="failure">the web exception</param>
        public override void OnException(Exception failure)
        {
            this.Users.Clear();
        }
    }
}
